<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>基础数据管理-项目信息新增</title>
    <script src="/scripts/boot.js"></script>
    <link href="/scripts/daterangepicker/js/daterangepicker.min.css" rel="stylesheet" type="text/css" />
    <script src="/scripts/daterangepicker/js/moment.js" type="text/javascript"></script>
    <script src="/scripts/daterangepicker/js/jquery.daterangepicker.min.js" type="text/javascript"></script>
    <script src="/scripts/daterangepicker/ux.daterangepicker.js" type="text/javascript"></script>
    <link href="/scripts/daterangepicker/css/skin.css" rel="stylesheet" type="text/css" />
    <!--//上传插件-->
    <link href="/scripts/webuploader/css/webuploader.css" rel="stylesheet" type="text/css" />
    <link href="/scripts/webuploader/css/style.css" rel="stylesheet" type="text/css" />
    <script src="/scripts/webuploader/js/webuploader.js"></script>
    <script src="/scripts/webuploader/js/upload.js"></script>
    <style>
        html,body{
            margin:0;padding: 0;border:0;width:100%;height:100%;overflow:auto;
        }
        body{
            background: #ffffff!important;
            padding:20px;
        }
    </style>
</head>
<body class="bg-white">
<div id="viewForm">
    <div class="title-info mb-20"><span>计划信息</span></div>
    <table class="table-bg" border="0" cellpadding="1" cellspacing="1" style="width:100%;table-layout:fixed;">
        <colgroup>
            <col width="135px"></col>
            <col width="50%"></col>
            <col width="135px"></col>
            <col width="50%"></col>
        </colgroup>
        <tr>
            <td class="text-titlebg">
                计划名称
            </td>
            <td>
                <div class="input-div color-66" id="planName"></div>
            </td>
            <td class="text-titlebg">
                节点名称
            </td>
            <td>
                <div class="input-div color-66" id="planNodeName"></div>
            </td>
        </tr>
        <tr>
            <td class="text-titlebg">计划类型</td>
            <td>
                <div class="input-div color-66" id="planTypeName"></div>
            </td>
            <td class="text-titlebg">
                计划起止日期
            </td>
            <td>
                <div class="input-div color-66" id="beginDate"></div>
            </td>
        </tr>
        <tr>
	        <td class="text-titlebg">是否完成</td>
	        <td >
                <div class="input-div color-66" id="isComplete"></div>
	        </td>
            <td class="text-titlebg">当前进度</td>
            <td>
                <div class="input-div color-66" id="currentProgress"></div>
            </td>
        </tr>
        <tr class="noBox">
        	<td class="text-titlebg">
                预计结束时间
            </td>
            <td colspan="3">
                <div class="input-div color-66" id="expectDate"></div>
            </td>
        </tr>
        <tr class="yesBox">
            <td class="text-titlebg">实际结束日期
            </td>
            <td colspan="3">
                <div class="input-div color-66" id="overDate"></div>
            </td>
        </tr>
        <tr>
            <td class="text-titlebg noEmpty">说明</td>
            <td colspan="3" class="wp">
                <div class="textarea-div color-66" id="remark"></div>

                <input name="id" id="planNodeId" class="mini-hidden"/>
            </td>
        </tr>
    </table>
    <div class="yesDataBox">
	<div class="title-info"><span>详细信息</span></div>
    <div id="datagrid1" class="mini-datagrid" style="width:100%;height:280px; margin-top: 35px;" idField="id" url="/monthlyPlanExecution/fruitArchivesDetailedListByPage"
         allowResize="true" pageSize="20" allowCellEdit="true" allowCellSelect="true" multiSelect="true"  editNextOnEnterKey="true"  editNextRowCell="true">
        <div property="columns">
            <!--<div type="checkcolumn" allowResize="false" width="15"></div>-->
            <div type="indexcolumn" allowResize="false" width="15">编号</div>
            <div   field="achievementName" name="achievementName" headerAlign="center" allowSort="true" width="80" allowResize="false">成果名称
            </div>
            <div field="achievementNature" name="achievementNature"  width="80" headerAlign="center" allowSort="true" allowResize="false">成果性质
            </div>
            <div field="achievementTime"  name="achievementTime" renderer="view.ondayRenderer" headerAlign="center"  width="40" allowSort="true" allowResize="false">成果取得时间
            </div>
            <div field="patternManifestation"  name="patternManifestation" width="50" allowSort="true" allowResize="false">表现形式
            </div>
            <div field="storagePlace"  name="storagePlace" width="50" allowSort="true" allowResize="false">原始资料存放位置
            </div>
            <div field="file_name" name="file_name"   headerAlign="center" allowSort="true" allowResize="false" renderer="view.onLoadFile2">已上传文件 <!--  renderer="view.getFile" -->
            </div>

        </div>
    </div>
    </div>
	
    
			<div class="attachment-box">
				<div class="attachment-title">
					<div class="attachment-text">
						<span class="blue-dot"></span>附件
					</div>
				</div>
				<div class="attachment-content">
		    		<div id="file_ll" class="updata-file"></div>
				</div>
			</div> 
    <div class="chose-toolbar">
        <a class="chose-button" onclick="CloseWindow('close')">关闭</a>
    </div>
</div>
<script src="/scripts/res/js/common.js"></script>
<script type="text/javascript">
    var post_flag,form,state,datas,beDate;
    var view = {
        init: function () {
            common.areaItem.init({
                idName:'#areaItem',
                isItem: true
            });
            post_flag = false; //设置一个对象来控制是否进入AJAX过程
            mini.parse();
            form = new mini.Form("#viewForm");
            
        },
        onLoadFile2 : function(e){
            var fileName;
        	$.ajax({
                url: "/fileCommon/loadFileList",
                type : "post",
                dataType: 'json',
                async: false,       //是否同步,默认true异步
                data:{"tableId":e.row.id,"tableName":"t_key_fruit_archives_detailed"},
            }).done(function(text) {
                if(text){
                    var listFile = text;
                    for(var i=0;i<listFile.length;i++ ){
                        var file = listFile[i];
                        var name =	"<a class='check-botton' onclick=\"view.downFile('" +file.fileUrl+"','"+file.fileName+"')\">" + file.fileName + "</a><br>";
                        if(!fileName){
                            fileName=name;
                        }else{
                            if(fileName){
                                fileName+=name;
                            }
                        }

                    }
                }
            });
            return fileName;
        	
        },
        onLoadFile : function(id){
        	$.ajax({
                url: "/fileCommon/loadFileList",
                type : "post",
                dataType: 'json',
                async: false,       //是否同步,默认true异步
                data:{"tableId":id,"tableName":"t_plan_feed_back"},
            }).done(function(text) {
                if(text){
                    var div = $("#file_ll");
                    var listFile = text;
                    for(var i=0;i<listFile.length;i++ ){
                        var file = listFile[i];
                        var a = "<div class='file-box' id='" + file.id + "'>"+
    	    			"<a class='file-name' onclick=\"downFile('" +file.fileUrl+"','"+file.fileName+"')\">" + file.fileName + "</a>"+
    	    			// "<span class='img-wh' onclick=\"delFile('" +fileid+"','"+url+"')\"></span>"+
        				"</div>";
                        div.append(a);

                    }
                }
            });
        	
        },
        downFile:function(url,name){
            window.location.href = "/ftp/downFile?path="+url+"&fileName="+name;
        },
//    数据展示
        SetData: function (data) {
            data = mini.clone(data);
            state = data.state;

            mini.get("planNodeId").setValue(data.id);
            $.ajax({
                url:"/planFeedBack/info?id=" + data.id,
                type: "post",
                success: function (text) {
                    var obj = JSON.parse(text);
                    //跨页面传递的数据对象，克隆后才可以安全使用
                    datas = mini.decode(obj.body[0]);   //反序列化成对象
                    $.each(datas,function (key,value) {
                        $("#"+key).html(value);
                        if(key=="beginDate"){
                            beDate=value;
                        }
                        if(key=="endDate"){
                            if(value){
                                beDate=beDate+" ~ "+value;
                            }
                        }
                        if(key=="expectDate"){
                        	if(value){
                                var d = new Date(value);
                                var youWant=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
                                $("#"+key).html(youWant);
                        	}else{
                                $("#"+key).html("");
                        	}
                        }
                        if(key=="overDate"){
                        	if(value){
                                var d = new Date(value);
                                var youWant=d.getFullYear() + '-' + (d.getMonth() + 1) + '-' + d.getDate();
                                $("#"+key).html(youWant);
                        	}else{
                                $("#"+key).html("");
                        	}
                        }
                        if(key=="currentProgress"){
                            $("#"+key).html(value+"%");
                        }
                        $("#beginDate").text(beDate);
                        

                        if(key=="isComplete"){
                            if(value=="1"){
                                $("#"+key).html("完成");
                            }else{
                                $("#"+key).html("未完成");
                            }
                        }
                    })
                    form.setData(datas);             //设置多个控件数据
                    // mini.get("date-range1").setValue(datas.beginDate +" ~ " +datas.endDate)
                    if(datas.isComplete==0){
                        $(".yesBox").hide();
                        $(".noBox").show();
                        $(".attachment-box").show();
                        $(".yesDataBox").hide();
                    }else{
                        $(".noBox").hide();
                        $(".yesBox").show();
                        $(".attachment-box").hide();
                        $(".yesDataBox").show();
                    }

                    mini.get("datagrid1").load({"keyFruitArchives.planFeedBack.id":data.id})
                    view.onLoadFile(data.id);
                }
            });
            if(data.state=="edit"){

            }else{
                $('input[name=id]').val("");
            }
        }
    };
    view.init();
</script>
</body>
</html>